package ext.vpde.cadvaulting.migration;

import java.io.*;
import java.util.Hashtable;
import java.util.StringTokenizer;

import ext.vpde.cadvaulting.util.WINDSQL;

public class ScanFileTypes {
	
	public static void main ( String [] args ) throws Exception {
		if (args.length != 1) {
			System.out.println("\nUsage: windchill ext.productcenter.ScanFileTypes loadfile");
		} else {
			WINDSQL.openConnection();
			readEntries(args[0]);
			WINDSQL.closeConnection();
		}
    }
	
	private static void readEntries(String LOADFILE) throws Exception {
		BufferedReader file = new BufferedReader(new FileReader(LOADFILE));
		String s = file.readLine();
		Hashtable ht = new Hashtable();
		while (s!= null && s.length() > 0) {	
			StringTokenizer strTok = new StringTokenizer(s,"|");
			String pName = strTok.nextToken();
			String pExt  = pName.substring(pName.indexOf(".")+1);

			if (!ht.containsKey(pExt)) ht.put(pExt,pExt);

			s = file.readLine();
		}
		System.out.println(ht.toString());
	}
}
